import 'package:flutter/material.dart';
class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("滚动列表"), // 标题
          leading: Icon(Icons.menu), // 左侧图标
          actions: [Icon(Icons.settings)],  // 右侧图标数组
          elevation: 0.0,// 去掉阴影
          centerTitle: true, // 标题居中

        ),
        body:SingleChildScrollViewDemo()
    );
  }
}

class SingleChildScrollViewDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        // 验证水平滚动
        SingleChildScrollView(
          scrollDirection: Axis.horizontal,
          padding: EdgeInsets.all(10),
          reverse: false,
          // 弹性下拉
          physics: BouncingScrollPhysics(),
          child: Row(
            children: [
              OutlinedButton(onPressed: null, child: Text("按钮1")),
              OutlinedButton(onPressed: null, child: Text("按钮2")),
              OutlinedButton(onPressed: null, child: Text("按钮3")),
              OutlinedButton(onPressed: null, child: Text("按钮4")),
              OutlinedButton(onPressed: null, child: Text("按钮5")),
              OutlinedButton(onPressed: null, child: Text("按钮6")),
              OutlinedButton(onPressed: null, child: Text("按钮7")),
              OutlinedButton(onPressed: null, child: Text("按钮8")),
            ],
          ),
        ),
        // 验证垂直滚动
        SingleChildScrollView(
          scrollDirection: Axis.vertical,
          padding: EdgeInsets.all(10),
          reverse: true,
          child: Column(
            children:List.generate(100, (index) => OutlinedButton(onPressed: (){}, child: Text("按钮$index")))
          ),
        ),
      ],
    );
  }
}
